<%@ page import="id.co.gomobile.assessment.Test" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>List of Tests</title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
    <div id="body">
    
    <h1>List of Tests</h1>
    
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    
    <div class="list">
    <table>
        <col width="50" />
        <col width="300" />
        <col />
        <col width="150" />
        <thead>
            <tr>
                <th colspan="4" align="right">${testInstanceList.size()} of ${testInstanceTotal} displayed</th>
            </tr>
            <tr>
                <g:sortableColumn property="id" title="${message(code: 'test.id.label', default: 'Id')}" />
                <g:sortableColumn property="name" title="${message(code: 'test.name.label', default: 'Name')}" />
                <g:sortableColumn property="description" title="${message(code: 'test.description.label', default: 'Description')}" />
                <th title="Action">Action</th>
            </tr>
        </thead>
        <tbody>
        <g:each in="${testInstanceList}" status="i" var="testInstance">
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td>${fieldValue(bean: testInstance, field: "id")}</td>
                <td>${fieldValue(bean: testInstance, field: "name")}</td>
                <td>${fieldValue(bean: testInstance, field: "description")}</td>
                <td style="text-align: center">
                    <g:form action="show" id="${testInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_table.png')}" alt="Show Test" />
                    </g:form>
                    &nbsp;
                    <g:form action="edit" id="${testInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_edit.png')}" alt="Edit Test" />
                    </g:form>
                    &nbsp;
                    <g:form action="delete" id="${testInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_delete.png')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" alt="Delete Question" />
                    </g:form>
                </td>
            </tr>
        </g:each>
        </tbody>
    </table>
    </div>
    <div class="paginateButtons">
        <g:paginate total="${testInstanceTotal}" />
    </div>
    
    <br/>
    
    <div class="buttons">
        <g:form>
            <span class="button"><g:actionSubmit class="create" action="create" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
        </g:form>
    </div>
    
    </div>
    </body>
</html>